import React, { Component, Suspense } from 'react'
import { routerRoot } from './config'
import { HashRouter as Router, Route, Switch } from 'react-router-dom'
import { Result } from 'antd'
// import Font from '@apps/frontDesk/index'
interface IProps { }
interface IStaes {
    hasError: boolean
}
export default class App extends Component<IProps, IStaes> {
    constructor(props: IProps) {
        super(props)
        this.state = {
            hasError: false
        }
    }
    static getDerivedStateFromError(error: any) {
        // 更新 state 使下一次渲染能够显示降级后的 UI
        return { hasError: true };
    }
    public render() {
        if (this.state.hasError) {
            // 你可以自定义降级后的 UI 并渲染<h1>Something went wrong.</h1>;
            return (
                <Result
                    status="404"
                    title="404"
                    subTitle="对不起，页面出错，请联系管理员!,或重新刷新页面！"
                />
            )
        }
        return (
            <Router>
                <Switch>
                    {routerRoot.map((item: any) => {
                        return (
                            <Route exact key={item.path} path={item.path} component={item.component} />
                        )
                    })}
                    {/* <Route exact key="font" path="/" component={Font}></Route> */}
                </Switch>
            </Router>
        )
    }
}